#include <iostream>
#include <vector>
using namespace std;
vector<int> temp;
int count;
void mergesort(vector<int>& a, int l, int r) {
    if(l >= r) return;
    int mid = (l + r) >> 1;
    mergesort(a, l, mid);
    mergesort(a, mid + 1, r);
    int x = l, y = mid + 1, i = 0;
    while(x <= mid && y <= r) {
        if(a[x] <= a[y]) {
            temp[i++] = a[x++];
        }else {
            temp[i++] = a[y++];
            count++;
        }
    }
    while(x <= mid) temp[i++] = a[x++];
    while(y <= r) temp[i++] = a[y++];
    for(int i = l; i <= r; i++) {
        a[i] = temp[i - l];
    }
}
int main() {
    int n;
    cin >> n;
    temp.resize(n);
    vector<int> a;
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    mergesort(a, 0, n);
    cout << count << endl;
    return 0;
}